<template>
  <div id="feedback">
    <van-nav-bar title="意见反馈" left-arrow left-text="返回" @click-left="onClickLeft" />
    <div class="content">
      <van-form @submit="onSubmit">
        <van-field
          class="texte"
          maxlength="150"
          show-word-limit
          v-model="req.content"
          rows="4"
          autosize
          type="textarea"
          placeholder="请输入留言"
        />
        <div style="margin: 16px;">
          <van-button round block type="info" native-type="submit">提交</van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>
<script>
import { feedbackAdd } from "@/apis/record";
export default {
  data() {
    return {
      req: {
        ty: "1", 
        typenm: "",
        imglist: "",
        content: "",
      },
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1); //返回上一层
    },
    onSubmit(values) {
        feedbackAdd (this.req)
         .then(res => {
          this.$toast("意见反馈成功");
          this.onClickLeft()
        })
        .catch(err => {
          if(err.msg){
            this.$toast(err.msg);
          }else{
            this.$toast("网络错误"); 
          }
        });

    }
  },
  
};
</script>
<style lang="less">
#feedback {
  .content {
    margin-top: 20px;
    .van-cell {
      width: 90%;
      margin: 0 auto;
      padding: 10px 16px;
      .text {
        width: 90%;
        margin: 0 auto;
      }
    }
  }
}
</style>